<html>
	<body>
		<p><b> Javascript display</b>
		<p><div id="display">&nbsp;</div>
	</body>
	<script type="text/javascript" src="Answer.js"></script>
	<script type="text/javascript" src="AnswerIP.js"></script>
	<script type="text/javascript" src="ArrayList.js"></script>
	<script type="text/javascript" src="Integer.js"></script>
	<script type="text/javascript" src="String.js"></script>
	<script type="text/javascript" src="Match.js"></script>
	<script type="text/javascript" src="IPChoice.js"></script>
	<script type="text/javascript" src="DNSLookup.js"></script>
	<script type="text/javascript" src="Response.js"></script>
	<script type="text/javascript" src="Response.js"></script>
	<script type="text/javascript" src="HistoryLookup.js"></script>
	<!--<script type="text/javascript" src="../../sample.js"></script>-->
	<script>
		var index = 0;

		// addMethod - By John Resig (MIT Licensed)
		function addMethod(object , name, fn ){
			var old = object[ name ];
			object[ name ] = function(){
				if ( fn.length == arguments.length )
				return fn.apply( this, arguments );
				else if ( typeof old == 'function' )
				return old.apply( this, arguments );
			};
		}

		function Class_test(text,text2)
		{
                        if( text )
				alert(text);
			else
				alert("!!!");
		} 


		function init(){
			var status = document.getElementById('display');
			status.innerHTML = '';
		}
		function display( text ){
			var id = 'phrase' + index++;
			var status = document.getElementById('display');
			status.innerHTML += '<span id="'+ id + '"></span><br>';
			var bullet = '(' + ( index ) + ') ';
			document.getElementById(id).innerHTML = bullet +'&nbsp;' + text ;
			
		}
		function test(){
			var list = new ArrayList();
			var a;
			list.add(new Integer(300) );
			list.add(new Integer(1) );
			list.add(500);

			var status = document.getElementById('display');
			//status.innerHTML = '';
			
			for( var i = 0 ; i < list.size() ; i++ )
			{
				var id = 'phrase' + index++;
				status.innerHTML += '<span id="'+ id + '"></span><br>';
				var bullet = '(' + ( index+ 1) + ') ';	
				document.getElementById(id).innerHTML =  bullet + '&nbsp;' + list.get(i) ;
			}
		}


		var db;
                //var result = new SQLResultSet();
		function websql(){
			private:
			var success = false;

			public:
			try{
				db = window.openDatabase("dependns", "1.1", "DepenDNS History Database",  1024 * 1024);	
				if(!db)
					alert('Could not create database: ');
			}
			catch (ex){
				alert('Could not create database: ' + ex.message);
			}
                        
			this.getDomainID = function( domain_name ){
				var sql;
				sql = "select id from domain_id where domain_name=?;";
				db.transaction( function(tx){
					tx.executeSql( sql,
					[domain_name],
					function(tx,rs){ 
						var result = rs.rows.item(0);
						display("Rs:"+result["id"] );
					},
					function(tx,err){ alert("Err:"+err);}
					);
				});
			}
		}                                                        
	        //tx.executeSql("INSERT INTO WebKitStickyNotes (id, note, timestamp, left, top, zindex) VALUES (?, ?, ?, ?, ?, ?)", 
		//[note.id, note.text, note.timestamp, note.left, note.top, note.zIndex]);	

		//var t = new Answer( 1 , "140.114.63.1");
		var resolvecount = 17;
		init();
		var IP = new ArrayList();
		//IP.add('140.114.63.1');
		//IP.add('140.114.64.1');
		//for ( var i = 0 ; i < IP.size() ; i++ )
		//	display( IP.get(i) );
          	//var d = new websql();
		//d.getDomainID("www.yahoo.com");
		var AnsList = new Answer( "140.114" , "140.114.63.1");
		for( var i = 0 ; i < resolvecount-1 ; i++ )
			AnsList.addIP("140.114.63.1");
		//var AnsList2 = new Answer( "140.114" , "140.114.63.1"); 
		var HisList = new Answer( "140.114" , "140.114.63.1");
		for( var i = 0 ; i < 5667 -1 ; i++ )
			HisList.addIP("140.114.63.1");
		var Ans = new ArrayList();
		var His = new ArrayList();
		Ans.add(AnsList);
		//Ans.add(AnsList2);
		His.add(HisList);
		var AnsIpList = AnsList.ipList.get(0);
		//display(Ans.size());
		var match = new Match( Ans , His , 1 );
		//match.runMatchAlgorithm(resolvecount);
		//var iplist = match.getIPListAll();
		//var region = match.getRegion();
		//var ipChoice = new IPChoice( iplist , region );
		//ipChoice.countGrade();
		var dnslookup = new DNSLookup();
		dnslookup.dodebug();

	</script>

</html>
